package employeedb;

import java.util.LinkedList;

/**
 *
 * @author Админ
 */
public class Worker {

    private String employee;
    private String role;
    private LinkedList<Project> projects;
    private double fixedSalary;
    private double experience;
    private double payroll;

    public Worker(String name, String role, LinkedList<Project> projects, double fixedSalary, double experience) {
        this.employee = name;
        this.role = role;
        if (role.equals("Developer") && projects.size() > 1) {
            throw new IllegalArgumentException("Developer может иметь только 1 проект");
        } else {
            this.projects = projects;
        }

        this.fixedSalary = fixedSalary;
        this.experience = experience;
    }

    public Worker payroll() {//возвращает сотрудника с расчитанным бонусом в поле currentpay
        this.payroll = fixedSalary;
        for (double i = this.experience; i >= 1; i--) {
            payroll += 50;
        }
        for (int i = 0; i < this.projects.size(); i++) {
            if (this.projects.get(i).getisFixedCost() == false) {
                payroll += 500;
            }
        }
        return this;
    }

    public String getEmployee() {
        return this.employee;
    }

    public double getPayroll() {//this.payroll();
        return this.payroll;
    }
}
